export interface Menu{
    id: number,
    label: string;
    name: string;
    code: string | null;
    sort: number;
    icon: string;
    iconName: string;
    grade: number,
    parentId: number,
    dictMenuType: string,
    path: string,
    type: string | number,
    remark?: string | null,
    children?: Menu[], 
    forSourceViewId?: number | null,
    sourceViewName?: string | null,
    forSourceReportId?: number | null,
    sourceReportName?: string | null,
}
// 递归函数，用于处理层级结构
export function processMenu(menu: Menu) {
    // console.log(1111,menu);
    const result: Menu = {
        id: menu.id,
        label: menu.name,
        code: menu.code,
        sort: menu.sort,
        icon: menu.iconName,
        grade: menu.grade,
        parentId: menu.parentId,
        path: menu.path,
        type: menu.dictMenuType,
        name: menu.name,
        iconName: menu.iconName,
        dictMenuType: menu.dictMenuType,
        remark: menu.remark,
        forSourceViewId: menu.forSourceViewId,
        sourceViewName: menu.sourceViewName,
        forSourceReportId: menu.forSourceReportId,
        sourceReportName: menu.sourceReportName,
    };
    // console.log(222,result);
    if (menu.children) {
        result.children = menu.children.map((child: any) => {
            return processMenu(child);
        });
    }

    return result;
}
